package com.gfeeling.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gfeeling.model.DataSourceTest1;
import com.gfeeling.model.DataSourceTest2;
import com.gfeeling.service.DataSource1Service;
import com.gfeeling.service.DataSource2Service;

@Controller
@RequestMapping("/data")
public class DataSourceController extends BaseController{
    @Autowired
    private DataSource1Service dataSource1Service;
    @Autowired
    private DataSource2Service dataSource2Service;
	@RequestMapping("/save")
	@ResponseBody
    public Map<String, Object> save() throws Exception{
		DataSourceTest1 test1 = new DataSourceTest1();
		test1.setEmail("lsl@163.com");
		test1.setName("lsl");
		dataSource1Service.save(test1);
		
		DataSourceTest2 test2 = new DataSourceTest2();
		test2.setUsername("lsl2");
		test2.setPassword("1234");
		dataSource2Service.save(test2);
    	return returnSuccess();
    }
	@RequestMapping("/list")
	@ResponseBody
    public Map<String, Object> list() throws Exception{
		dataSource1Service.findAll(new DataSourceTest1());
		dataSource2Service.findAll(new DataSourceTest2());
		map.put("data", dataSource1Service.findAll(new DataSourceTest1()));
		map.put("data1",dataSource2Service.findAll(new DataSourceTest2()));
    	return returnSuccess();
    }
}
